/*
 +-----------------------------------------------------------------------------------------------+
 | Project : UKAPI
 +-----------------------------------------------------------------------------------------------+
 | Project Description : Universal & Kernel API
 +-----------------------------------------------------------------------------------------------+
 | File Description :
 |   Device Request
 |                                                 
 +-----------------------------------------------------------------------------------------------+
 | Licence : MIT Licence
 +-----------------------------------------------------------------------------------------------+
 | Copyright (c) 2006 Olivier Vanhoucke
 | 
 | Permission is hereby granted, free of charge, to any person obtaining a copy of this software 
 | and associated documentation files (the "Software"), to deal in the Software without 
 | restriction, including without limitation the rights to use, copy, modify, merge, publish, 
 | distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the 
 | Software is furnished to do so, subject to the following conditions:
 | 
 | The above copyright notice and this permission notice shall be included in all copies or 
 | substantial portions of the Software.
 | 
 | THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING
 | BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND 
 | NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, 
 | DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, 
 | OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
 +-----------------------------------------------------------------------------------------------+
*/

#ifndef __UKAPI_KERNEL_DEVICE_REQUEST__
#define __UKAPI_KERNEL_DEVICE_REQUEST__

#include <stream_driver.h>
#include <buffer.h>
#include <event.h>
#include <message.h>

typedef enum
{
	device_request_type_read_e,
	device_request_type_write_e,
	device_request_type_seek_e,
	device_request_type_iocontrol_e,
	device_request_type_power_on_e,
	device_request_type_power_off_e,
	device_request_type_open_e,
	device_request_type_close_e,
} device_request_type_t, * pdevice_type_request_t;

typedef struct
{
	device_request_type_t	request_type;
	pevent_t				pevent_ack;
	pstream_driver_t		stream_driver;
	pbuffer_t				buffer_in;
	pbuffer_t				buffer_out;
} device_request_t, * pdevice_request_t;

#ifdef __cplusplus
	extern "C" {
#endif /* __cplusplus */

pdevice_request_t device_request_create( pstream_driver_t device, device_request_type_t device_request_type, pbuffer_t pbuffer_in, pbuffer_t pbuffer_out );
result_t device_request_send( pdevice_request_t pdr ); 
result_t device_request_sendack( pdevice_request_t pdr ); 
result_t device_request_wait( pmessage_t * pmsg );
result_t device_request_waitack( pdevice_request_t pdr );
result_t device_request_destroy( pdevice_request_t pdr );

#ifdef __cplusplus
	}
#endif /* __cplusplus */

#endif /* __UKAPI_KERNEL_DEVICE_REQUEST__ */
